//
//  showAlertView.m
//  HappyStore
//
//  Created by 陈锋 on 16/8/2.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "showAlertView.h"

#define IMAGE_WIDTH 70
#define LABEL_WIDTH 240
#define LABEL_HEIGHT 10

@implementation showAlertView

-(UIView *)alertView{
    if (!_alertView) {
        UIWindow *window =[UIApplication sharedApplication].keyWindow;
        _alertView=[[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
        _alertView.backgroundColor =[[UIColor blackColor]colorWithAlphaComponent:0.5];
        [window addSubview:_alertView];
    }
    
    return _alertView;
}

+ (void)showAlertView:(BOOL)isSucess{
    
    

}

- (void)show:(BOOL)isSucess{
    
    UIView *subview =[[UIView alloc] init];
    CGSize viewSize = CGSizeMake(screenW-30, 171);
    subview.backgroundColor = [UIColor whiteColor];
    subview.center = self.alertView.center;
    subview.bounds =  (CGRect){CGPointZero, viewSize};
    subview.layer.cornerRadius = 6.0;
    
    //设置图标  和 提示文字
    UIImageView *imageIcon = [[UIImageView alloc]initWithFrame:CGRectMake((subview.width-IMAGE_WIDTH)/2, 30, IMAGE_WIDTH, IMAGE_WIDTH)];
    
    UILabel *announceLabel = [[UILabel alloc] initWithFrame:CGRectMake(imageIcon.x+10, imageIcon.y+IMAGE_WIDTH+15, 500, 10)];
    announceLabel.font = [UIFont systemFontOfSize:12];
    UILabel *secondLineLable  =[[UILabel alloc] init];
    secondLineLable.frame= CGRectMake((subview.width-LABEL_WIDTH)/2, announceLabel.y+LABEL_HEIGHT+6, LABEL_WIDTH+15, LABEL_HEIGHT);
    secondLineLable.font = [UIFont systemFontOfSize:12];
    // secondLineLable.adjustsFontSizeToFitWidth =YES;
    
    if (isSucess) {
        imageIcon.image = [UIImage imageNamed:@"success"];
        announceLabel.text = @"提交成功";
        secondLineLable.text = @"请耐心等待，我们会在3-7个工作日为您处理！" ;
    }
    else{
        imageIcon.image = [UIImage imageNamed:@"loginfail"];
        announceLabel.text = @"提交失败";
        secondLineLable.frame = CGRectMake((subview.width-LABEL_WIDTH+60)/2, announceLabel.y+LABEL_HEIGHT+6, LABEL_WIDTH-60, LABEL_HEIGHT);
        secondLineLable.text = @"你的网络不稳定，请重新提交！" ;
    }
    
    [subview addSubview:secondLineLable];
    [subview addSubview:announceLabel];
    [subview addSubview:imageIcon];
    [self.alertView addSubview:subview];


}
@end
